<script setup lang="ts">
import TopNav from '@/components/TopNav.vue';
import { inject, Ref } from 'vue';

const asideVisible = inject<Ref<boolean>>('asideVisible');
</script>

<template>

  <top-nav aside-button-visible />

  <div class="layout">

    <transition name="slide">
      <aside v-show="asideVisible">
        <h2>文档</h2>
        <ol>
          <li><router-link to="/doc/intro">介绍</router-link></li>
          <li><router-link to="/doc/install">安装</router-link></li>
          <li><router-link to="/doc/get-started">开始使用</router-link></li>
        </ol>
        <h2>组件列表</h2>
        <ol>
          <li><router-link to="/doc/switch">Switch 组件</router-link></li>
          <li><router-link to="/doc/button">Button 组件</router-link></li>
          <li><router-link to="/doc/dialog">Dialog 组件</router-link></li>
          <li><router-link to="/doc/tabs">Tabs 组件</router-link></li>
        </ol>
      </aside>
    </transition>

    <main>
      <router-view />
    </main>

  </div>
</template>

<style scoped lang="scss">
.layout {
  height: calc(100vh - 81px);
  display: flex;
  position: relative;
}

aside {
  width: 300px; height: 100%;
  background: #fff;
  overflow-y: auto;
  padding: 0 40px;
  position: absolute; left: 0; top: 0;
  z-index: 1;
  > h2 {
    margin: 16px 0;
  }
  > ol > li {
    padding: 4px 0;
    > a {
      display: block;
      padding: 4px 16px;
    }
    .router-link-active {
      color: #409eff; font-weight: bold;
      background: rgba(64, 158, 255, .1);
      border-radius: 8px;
    }
  }
}

main {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 16px; margin-left: 300px;
}

@media (max-width: 500px) {
  aside { width: 100%; }
  main { margin-left: 0; }
}
</style>
